<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>RSS History filter for OpenStreetMap.org</title>
<link rel="stylesheet" type="text/css" href="main.css">
<link rel="stylesheet" type="text/css" href="osmfilter.css">
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript" src="sect_hide.js"></script>
<script  type="text/javascript" language="javascript">
	function getUrl() {
		var source_url = $("#source_url");
		var source = source_url.val();
		if(!source || source=="") { alert("Enter some URL into the text field above"); return; }
		var slat = $("#slat").val();
		var slon = $("#slon").val();
		var numRegex = /\d+(\.\d+)?/;
		if(!numRegex.test(slat) ) { alert("Latitude limit is not a decimal number!"); return; }
		if(!numRegex.test(slon) ) { alert("Longitude limit is not a decimal number!"); return; }

		var url = $("#url");
		url.show();
		url.html("getting...");
		var req = $.ajax({
		  url: "extractfeed",
		  data: { url: source_url.val() },
		  dataType: "json"
		}).done(function( msg ) {
			if(msg.result) {
				var dst = 'http://positron96.appspot.com/osmfilter.rss?feed='+
					encodeURIComponent(msg.url)+
					'&slat='+slat+
					"&slon="+slon;
				url.html('<div class="urldata">'+
					'This is a link to filtered feed:'+
					'<a href="'+dst+'">'+dst+'</a>'+
					'You can copy and paste it into your favorite RSS-aggregator</div>');
			} else {
				url.html('<div class="error">'+msg.message+'</div>');
			}
		});
		req.fail(function() {url.html('<div class="error">Something nasty happened</div>')});
	}

	$(document).ready(function() {
		$(".a_show").html("[show details]");
		$(".a_hide").html("[hide]");
		//$(".a_show").click( function(obj) {sect_show(obj.attr("id")) });
    });
</script>
</head>
<body>
<div id="cont">
	<div class="cont_vis">
		<h1>RSS History Filter for OpenStreetMap.org</h1>
		<form>
		<p>Input URL of history page from openstreetmap.org:
		<p><input type="text" name="url" id="source_url">
		<p>Latitude limit: <input type="text" id="slat" name="slat" class="num" value="20">deg.&nbsp;&nbsp;&nbsp;
		Longitude limit: <input type="text" id="slon" name="slon" class="num" value="40">deg.
		<p><input type="submit" onclick="getUrl();return false;" value="Get filtered RSS URL">&nbsp;
			<input type="reset" value="Reset form">
		</form>
	</div>
	<div id="url" style="display:none"></div>
</div>
<h2>Description</h2>
<p>This site will allow you to filter out large changesets from
RSS feed generated from OpenStreetMap history tab. It is very useful since
these feeds are usually filled with bot-generated changes that cover half of the
world and do not change area that you are monitoring.

<p>Technically, it loads RSS items from the source feed, and drops those that are
larger than 20 degrees latitude or 40 degrees longitude (or values provided by users
at feed creation time).

<h2>Development</h2>
The project is at development stage, so any comments, suggestions and reports are welcome.
Please visit <a href="http://code.google.com/p/openstreetmaps-rss-geofilter/">project site at google code</a>.
<h2>Usage</h2>
<div class="help">
	<p>Usage of the service is quite simple. Just follow these steps:
	<ol>
		<li><span class="head">Copy the URL of hisotry page on OpenStreetMaps site</span>
			<a href="javascript:sect_show('copy')" id="a_copy" class="a_show"></a>
			<div class="section" id="s_copy">
				<a href="javascript:sect_hide('copy')" class="a_hide"></a>
				When you want to track changes on a certain area, you usually go to
				history tab to look at changesets list. Go there now:
				<p>
				<img src="help/help1.png">
				<p>
				You need to copy URL of the history page to clipboard.
				This can usually be done by clicking somewhere in the address tab
				and pressing Ctrl+C or selecting "Copy" from context menu.
				<p><img src="help/help2.png">
			</div>
		</li>
		<li><span class="head">Paste it into the textbox above</span>
			<a href="javascript:sect_show('paste')" id="a_paste" class="a_show"></a>
			<div class="section" id="s_paste">
				<a href="javascript:sect_hide('paste')" class="a_hide"></a>
				OK, URL is now copied to your clipboard. Now paste it into
				the textbox above. (Press Ctrl+V or select "Paste" from context-menu)
				<p><img src="help/help4.png">
				<p>The correct URL looks like this:</p>
				<p><img src="help/url.png">
				<p>Please make sure that it does not start with quotes.
			</div>
		</li>
		<li><span class="head">Tweak filtering options, or leave them as they are</span>
			<a href="javascript:sect_show('tweak')" id="a_tweak" class="a_show"></a>
			<div class="section" id="s_tweak">
				<a href="javascript:sect_hide('tweak')" class="a_hide"></a>
				You can also tweak filtering threshold for your needs.
				At the moment you can modify filtering area size. By default,
				the feed will contain changesets smaller than 20 degrees latitude and 40 degrees
				longitude. You can change that via "Latitude limit" and "Longitude limit" textboxes.
				Input float or integer numbers there, like this:
				<p><img src="help/help3.png">
			</div>
		</li>
		<li><span class="head">Click "Get filtered RSS URL" button</span>
		</li>
		<li><span class="head">Use that URL as you prefer</span>
			<a href="javascript:sect_show('use')" id="a_use" class="a_show"></a>
			<div class="section" id="s_use">
				<a href="javascript:sect_hide('use')" class="a_hide"></a>
				<img src="help/help5.png">
				<p>
				That's it!
				The link leads to a feed that contains the very same data as the original feed
				except that it drops large changesets.
				<p>You can just click the link if you want to use an aggregator built into your browser
				(like Internet Explorer,  Firefox, Opera) or copy and paste it into  your
				favorite RSS aggregator or on-line feed readers like Google Reader.
			</div>
		</li>

	</ol>
</div>
<h3>You can also create a link manually</h3>
At the moment, basic usage syntax for the service is:
<pre>
<code>http://positron96.appspot.com/osmfilter.rss?feed={feed}&amp;slat={lat}&amp;slon={lon}</code></pre>
where
<ul>
	<li>{feed} is the source RSS URL you usually subscribe to at OpenStreetMap.org site.
		Note that it is <i>not</i> an URL of history page of the OpenStreetMap.org site.
		This URL should be escaped to be a correct parameter (as described in
		<a href="http://www.w3.org/TR/html4/interact/forms.html#h-17.13.4.1">HTML specification</a>)
	<li>{lat} is latitude threshold, in degrees.
	<li>{lon} is longitude threshold in degrees.
</ul>
<span class="note">Parameters <code>slat={lat}&amp;slon={lon}</code> can be omitted.</span>
</div>
<hr>
<h6>2012, by Paul Melnikov, positron{ninetysix}{at}gmail.com</h6>
</body>
</html>